package com.xin.di.uav.common.utils;

import com.xin.di.uav.common.enums.BaseResponseCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 返回结果基础类
 * @author ta136817
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RespJson {
    /**
     * 响应编号
     */
    private String responseCode;

    /**
     * 响应信息
     */
    private String responseMessage;


    /**
     * 返回成功
     * @return
     */
    public static RespJson success() {
        return restResult(BaseResponseCode.SUCCESS.getResponseCode(), BaseResponseCode.SUCCESS.getResponseMessage());
    }

    /**
     * 返回成功
     * @return
     */
    public static RespJson success(BaseResponseCode baseResponseCode) {
        return restResult(baseResponseCode);
    }

    /**
     * 返回失败
     * @return
     */
    public static RespJson fail() {
        return restResult(BaseResponseCode.FAIL.getResponseCode(), BaseResponseCode.FAIL.getResponseMessage());
    }


    /**
     * 返回失败
     * @return
     */
    public static RespJson fail(BaseResponseCode baseResponseCode) {
        return restResult(baseResponseCode);
    }

    /**
     *
     * @param responseCode
     * @param responseMessage
     * @return
     */
    public static RespJson fail(String responseCode,String responseMessage) {
        return restResult(responseCode, responseMessage);
    }


    /**
     * 返回对象
     * @param baseResponseCode
     * @return
     */
    private static RespJson restResult(BaseResponseCode baseResponseCode) {
        return restResult(baseResponseCode.getResponseCode(), baseResponseCode.getResponseMessage());
    }

    /**
     * 返回对象
     * @param responseCode
     * @param responseMessage
     * @return
     */
    private static RespJson restResult(String responseCode, String responseMessage) {
        RespJson respJson = new RespJson();
        respJson.setResponseCode(responseCode);
        respJson.setResponseMessage(responseMessage);
        return respJson;
    }
}
